<template>
  <view>
    <!-- 轮播 -->
    <swiper>
      <swiper-item v-for="item in banners" :key="item.ad_position_id">
        <img :src="item.image_url" alt="" class="swiper-img">
      </swiper-item>
    </swiper>
    <!-- 导航 -->
    <view class="nav">
      <view class="nav-content" v-for="(item,key) in nav" :key="key.id">
        <img :src="item.icon_rul" alt="" class="nav-img">
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        banners:[],   //轮播图
        nav:[],       //导航
      };
    },
    methods: {
      // 获取首页数据
      async getcontent(){
        let res = await uni.$http.get('index/index')
        console.log(res);
      },
      async getbanner(){
        let {data:{banner:res}} = await uni.$http.get('index/index')
        this.banners = res;
        // console.log(res);
      },
      async getnav(){
        let {data:{channel:res}} = await uni.$http.get('index/index')
        this.nav = res;
        console.log(res);
      }
    },
    onLoad() {
      this.getcontent()
      this.getbanner()
      this.getnav()
    }
  }
</script>

<style lang="scss">
.swiper-img{
  width: 100%;
}
</style>
